Playing
a Device
The play
Most devices
that support the play command also support the from (MCI_FROM) and
to (MCI_TO) flags. These flags indicate the position at which the device should
start and stop playing. For example, the following command plays a CD audio
disc from the beginning of the first track:
mciSendString("play cdaudio from 0",
lpszReturnString,
lstrlen(lpszReturnString), NULL);
Some device
types extend this command to exploit the capabilities of a particular device.
For example, the play
Note The units
assigned to the position value depend on the time format used by the device.
Each device has a default time format, but you should specify the time format
by using the set
(MCI_SET )
command before issuing any commands that use position values.
Playing an AVI File
Video files
in Windows are made up of at least two interleaved data streams: a video
(pictorial) stream and an audio stream. You can easily play these audio-video
interleaved (AVI) files by using MCI commands. The following sections discuss
playing AVI files.
Setting Up an MCIAVI Playback Window
Your
application can specify the following options to define the playback window for
playing an AVI file:
Use the MCIAVI driver s default
pop-up window.
Specify a parent window and
window style that the MCIAVI driver can use to create the playback window.
Specify a playback window for
the MCIAVI driver to use for playback.
Play the AVI file on a
full-screen display.
If your
application does not specify any window options, the MCIAVI driver creates a default
window for playing the sequence. The driver creates this playback window for
the open
Your
application can also specify a parent window handle and a window style when it
issues the open command. In this case, the MCIAVI driver creates a
window based on these specifications instead of the default pop-up window. Your
application can specify any window style available for the CreateWindow
Your
application can also create its own window and supply the handle to the MCIAVI
driver by using the window
When the
MCIAVI driver creates the playback window or obtains a window handle from your
application, it does not display the window until your application either plays
the sequence or sends a command to display the window. Your application can use
the window command to display the window without playing the sequence.
For example, the following command displays the window using the command-string
interface:
mciSendString("window movie state
show", lpszReturnString,
lstrlen(lpszReturnString), NULL);
In this example,
movie is an alias for the digital-video device.
Your
application can also play an AVI file full-screen. To play full-screen, modify
the play
mciSendString("play movie
fullscreen", lpszReturnString,
lstrlen(lpszReturnString), NULL);
Changing the Playback State for an AVI
file
Your
application can use the seek
Some MCI commands
let your application alter the playback of an AVI file in other ways. For
example, an AVI file, by default, plays at its normal speed, but your
application can increase or decrease this speed by using the speed flag with
the set command. For AVI files, a speed value of 1000 is typical. Thus,
to play a movie at half its typical speed, your application can use the command
set movie speed 500 ; alternatively, it can use set movie speed
2000 to play the sequence at twice its normal speed.
The setaudio
The MCIAVI
driver has a dialog box to control some of its playback options. Some of the
options available to the user include selecting window-oriented or full-screen
playback, selecting the seek mode, and zooming the image. Your application can
have MCIAVI display this dialog box by using the configure
Stream Handlers
The data in
an AVI file is treated as a series of streams. An AVI file typically contains
an audio and video stream, and there might also be a custom stream that
contains text or some other custom data. The MCIAVI driver can use different
handlers for these data streams. For more information about custom AVI files,
see Custom File and Stream Handlers